package com.nowcodercommunity.controller;

import com.nowcodercommunity.service.AlphaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@Controller
@RequestMapping("/Alpha")
public class AlphaController {

    @Autowired
    private AlphaService alphaService;

    @RequestMapping("/select")
    @ResponseBody
    public String select(){
        return alphaService.select();
    }

    @RequestMapping(path="/get", method= RequestMethod.GET)
    @ResponseBody
    public String getSome(
            @RequestParam(name="current" , required = false, defaultValue = "1") int current,
            @RequestParam(name="limit"   , required = false, defaultValue = "10") int limit){
        System.out.println(current+" "+limit);
         return "some student";
    }

    @RequestMapping(path="/getOne/{id}",method = RequestMethod.GET)
    @ResponseBody
    public String getOne(@PathVariable("id") int id){
        System.out.println(id);
        return "a student";
    }

    @RequestMapping(path="/postStudent" , method = RequestMethod.POST)
    @ResponseBody
    public String postStudent(String name, int age){
        System.out.println("姓名："+name+" 年龄："+age);

        return "success";
    }
}
